<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<% String path=request.getContextPath();
pageContext.setAttribute("path", path);

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>博客登录注册</title>
<link rel="stylesheet" href="${path }/static/css/index.css">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<section id="content">
    <!--头部-->
    <div class="content-header clearfix">
        <a href="javascript:;" class="current">登录</a>
        <a href="javascript:;">注册</a>
    </div>
    <!--内容-->
    <div class="content-body">
        <div class="dom" style="display: block;">
            <form action="${path }/StaticToLoginAndRegister?st=login" method="post">
                <div class="s1">
                    <h4>账号</h4>
                    <input name="email" type="email" placeholder="邮箱">
                </div>
                <div class="s1">
                    <h4>密码</h4>
                    <input name="password" type="password" placeholder="请输入密码">
                </div>
                <div class="s2">
                    <input type="checkbox">
                    <span>记住密码</span>
                </div>
                <input type="submit" class="btn" value="登&nbsp;录">
            </form>
            <div class="dom-footer">
                <div class="login-another">
                    <a href="#">找回密码</a>
                    <span>|</span>
                </div>
                <div class="login-three">
                    <span>使用第三方账号直接登录</span>
                    <div class="login-icon">
                        <a href="#">
                            <img src="${path }/static/img/qq.png" alt="">
                        </a>
                        <a href="#">
                            <img src="${path }/static/img/wechat.png" alt="">
                        </a>
                    </div>
                </div>
            </div>
        </div>
        <div class="dom">
            <form action="${path }/StaticToLoginAndRegister?st=register" method="post">
                <div class="s1">
                    <h4>用户名</h4>
                    <input name="email" type="email" placeholder="邮箱">
                </div>
                <div class="s1">
                    <h4>密码</h4>
                    <input name="password1" type="text" placeholder="6-30位英文、数字、符号, 区分大小写">
                </div>
                <div class="s1">
                    <h4>确认密码</h4>
                    <input name="password2" type="text" placeholder="6-30位英文、数字、符号, 区分大小写">
                </div>
                <input type="submit" class="btn" value="注&nbsp;册">
            </form>
            <div class="dom-footer">
                <div class="login-three">
                    <span>使用第三方账号直接登录</span>
                    <div class="login-icon">
                        <a href="#">
                            <img src="${path }/static/img/qq.png" alt="">
                        </a>
                        <a href="#">
                            <img src="${path }/static/img/wechat.png" alt="">
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
<script>
    window.onload = function () {
        // 1.1 获取需要的标签
        let as = document.getElementsByClassName('content-header')[0].getElementsByTagName('a');
        let contents = document.getElementsByClassName('dom');

        // 1.2 遍历
        for (let i = 0; i < as.length; i++) {
            // 1.2.1 取出单个对象
            let a = as[i];
            a.id = i;

            // 1.2.2 监听鼠标的移动事件
            a.onclick = function () {
                // 让所有的a的class都清除
                for (let j = 0; j < as.length; j++) {
                    as[j].className = '';
                    contents[j].style.display = 'none';
                }

                // 设置当前a的class
                this.className = 'current';
                // 从contents数组中取出对应的标签
                contents[this.id].style.display = 'block';
            }

        }
    }
</script>
</body>
</html>